package com.lmk.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.lmk.User;
import com.lmk.feign.UserService;
import com.lmk.sentinel.Currentlimiting;
import com.lmk.sentinel.getUserByIdfallback;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/order")
@RestController
public class OrderController {
    @Autowired
    private UserService userService;

    @GetMapping("/getUserById/{id}")
    @SentinelResource(
    value = "order-getUserById",
    blockHandler = "Currentlimitingmethod",
    blockHandlerClass = Currentlimiting.class,
    fallback = "fallbackmethod",
    fallbackClass = getUserByIdfallback.class
    )
    public User getUserById(@PathVariable("id") Long id){
        return userService.getUserById(id);
    }
}
